package com.water.app.Config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class ThreadPoolConfig {
    @Bean(name = "shoppingThreadPool")
    public ThreadPoolExecutor createShoppingThreadPool(){
        return new ThreadPoolExecutor(8,10,30, TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(10),
                (r)->new Thread(r,"Thread-"+System.currentTimeMillis()),
                new ThreadPoolExecutor.AbortPolicy());
    }
}
